<template>
  <div class="topic">
    <van-list
      v-model="loading"
      :finished="finished"
      finished-text="没有更多了"
      @load="onLoad"
    >
      <topic-list :recommendList="recommendList"></topic-list>
    </van-list>
  </div>
</template>

<script>
import { getListAction, getDetailaction } from "@/network/topic";
import {Toast} from 'vant'
import TopicList from "./children/TopicList";
export default {
  name: "index",
  components: {
    TopicList,
  },
  data() {
    return {
      loading: false,
      finished: false,
      recommendList: [],
      start: 1,
    };
  },
  created() {
    // this.getListActions();
  },
  methods: {
    getListActions() {
      const datas = {
        page: this.start,
      };
      getListAction(datas).then((res) => {
        console.log(res);
        // this.recommendList = res.recommendList
        this.recommendList.push(...res.data);
        console.log(this.recommendList);
        this.loading = false;
        Toast.loading({
          message: "加载中...",
          forbidClick: true,
          loadingType: "spinner",
          duration: 500,
        });
        this.start++;
        if (this.start > res.total) {
          this.finished = true; // 控制是否停止加载
        }
      });
    },
    // 加载数据
    onLoad() {
      this.getListActions();
    },
  },
};
</script>

<style lang="scss" scoped>
.topic {
  background-color: #f4f4f4;
}
</style>
